package dreampack.dataType;

//import java.util.*;
import java.sql.*;
import java.util.Calendar;

public abstract class UserBase {
	private int userId;
	private String userName;
	private String userPwd;
	private int userRole;
	private String realName;
	private String nickName;
	private String sex;
	private Timestamp birthday;
	private String headImage;
	private String telephone;
	private String email;
	private String msn;
	private String qq;
	private String address;
	private String postalCode;
	private String selfIntroduce;
	private Timestamp lastLogTime;
	
	protected UserBase(){}
	
	protected boolean init(ResultSet rs) throws Exception{
		boolean bRet = true;
		try{
			this.userId = (int)rs.getInt("id");
			this.userName = (String)rs.getString("name");
			this.userPwd = (String)rs.getString("password");
			this.userRole = (int)rs.getInt("role");
			this.realName = (String)rs.getString("realname");
			this.nickName = (String)rs.getString("nickname");
			this.sex = (String)rs.getString("sex");
			this.birthday = (Timestamp)rs.getTimestamp("birthday");
			this.headImage = (String)rs.getString("headimage");
			this.telephone = (String)rs.getString("telephone");
			this.email = (String)rs.getString("email");
			this.msn = (String)rs.getString("msn");
			this.qq = (String)rs.getString("qq");
			this.address = (String)rs.getString("address");
			this.postalCode = (String)rs.getString("postalcode");
			this.selfIntroduce = (String)rs.getString("self-introduce");
			this.lastLogTime = (Timestamp)rs.getTimestamp("lastlogtime");
		}catch(Exception e){
			bRet = false;
		}
		return bRet;
	}
	protected int getId(){
		return this.userId;
	}
	protected String getName(){
		return this.userName;
	}
	protected String getPassword(){
		return this.userPwd;
	}
	protected int getRole(){
		return this.userRole;
	}
	protected String getRealName(){
		return this.realName;
	}
	protected String getNickName(){
		return this.nickName;
	}
	protected String getSex(){
		return this.sex;
	}
	protected java.util.Date getBirthday(){
		java.util.Date tempDate = null;
		if (null != this.birthday) {
			Calendar cal = Calendar.getInstance();
			cal.setTimeInMillis(this.birthday.getTime());
			tempDate = cal.getTime();
		}
		return tempDate;
	}
	protected String getHeadImage(){
		return this.headImage;
	}
	protected String getTelephone(){
		return this.telephone;
	}
	protected String getEmail(){
		return this.email;
	}
	protected String getMsn(){
		return this.msn;
	}
	protected String getQQ(){
		return this.qq;
	}
	protected String getAddress(){
		return this.address;
	}
	protected String getPostalCode(){
		return this.postalCode;
	}
	protected String getSelfIntroduce(){
		return this.selfIntroduce;
	}
	protected java.util.Date getLastLogTime(){
		java.util.Date tempDate = null;
		if (null != this.lastLogTime) {
			Calendar cal = Calendar.getInstance();
			cal.setTimeInMillis(this.lastLogTime.getTime());
			tempDate = cal.getTime();
		}
		return tempDate;
		
	}
}
